package com.stylefeng.guns.modular.vpn.timer;

import com.stylefeng.guns.modular.vpn.utils.BusinessTaskUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * 业务数据统计定时任务
 */
@Slf4j
public class StatisticsQuartzJob implements Job {
    @Autowired
    @Qualifier("businessTaskUtil")
    BusinessTaskUtil businessTaskUtil;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //TODO 进行任务的处理，
        System.out.println("进行任务的处理");
        log.info("定时任务开始处理>>>>>>>>>>>>>>>>>>");

        try {
            businessTaskUtil.statisticsUserInfo();
            log.info("统计完拉新数据>>>>>>>>>>>>>>>>>>");
        } catch (Exception e) {
            log.error("统计拉新数据出错，{}",e.getMessage());
//            e.printStackTrace();
        }

        try {
            businessTaskUtil.statisticsFinancialInfo();
            log.info("统计完财务数据>>>>>>>>>>>>>>>>>>");
        } catch (Exception e) {
            log.error("统计财务数据出错，{}",e.getMessage());
//            e.printStackTrace();
        }

        try {
            businessTaskUtil.statisticsFinancialPackageInfo();
            log.info("统计完套餐数据>>>>>>>>>>>>>>>>>>");
        } catch (Exception e) {
            log.error("统计套餐数据出错，{}",e.getMessage());
//            e.printStackTrace();
        }

        try {
            businessTaskUtil.statisticsRetentionUserInfo();
            log.info("统计完留存数据>>>>>>>>>>>>>>>>>>");
        } catch (Exception e) {
            log.error("统计留存数据出错，{}",e.getMessage());
//            e.printStackTrace();
        }

        log.info("定时任务处理完成<<<<<<<<<<<<<<<<<<<<<<<");
    }
}
